feat: add C implementation for stats/base/ndarray/dminsorted#10134
feat: add C implementation for stats/base/ndarray/dminsorted#10134Om-A-osc wants to merge 5 commits intostdlib-js:developfrom
Conversation
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: passed
- task: lint_c_examples
status: passed
- task: lint_c_benchmarks
status: passed
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
|
@Sachinn-64 Thank you for pointing it out. I have made the necessary changes. |
|
@Sachinn-64 Done! |
| for ( i = 0; i < len; i++ ) { | ||
| data[ i ] = ( rand_double() * 20000.0 ) - 10000.0; | ||
| } | ||
| qsort( data, len, sizeof( double ), compare ); |
There was a problem hiding this comment.
| qsort( data, len, sizeof( double ), compare ); | |
Same here, I don’t think we need this part.
There was a problem hiding this comment.
@kgryte @Sachinn-64 package expects sorted data. If we remove the sorting logic then input will be invalid. What do you suggest ?
One thing we can do is fill the array like for ( i = 0; i < len; i++ ) { x[ i ] = i; }. should i go ahead with it ?
| for ( i = 0; i < len; i++ ) { | ||
| data[ i ] = ( rand_double() * 20000.0 ) - 10000.0; | ||
| } |
There was a problem hiding this comment.
| for ( i = 0; i < len; i++ ) { | |
| data[ i ] = ( rand_double() * 20000.0 ) - 10000.0; | |
| } | |
We could use a simple for loop here!
| /** | ||
| * Compares two double-precision floating-point numbers. | ||
| * | ||
| * @param a first value | ||
| * @param b second value | ||
| * @return comparison result | ||
| */ | ||
| static int compare( const void *a, const void *b ) { | ||
| const double *x = (const double *)a; | ||
| const double *y = (const double *)b; | ||
| if ( *x < *y ) { | ||
| return -1; | ||
| } | ||
| if ( *x > *y ) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
| /** | |
| * Compares two double-precision floating-point numbers. | |
| * | |
| * @param a first value | |
| * @param b second value | |
| * @return comparison result | |
| */ | |
| static int compare( const void *a, const void *b ) { | |
| const double *x = (const double *)a; | |
| const double *y = (const double *)b; | |
| if ( *x < *y ) { | |
| return -1; | |
| } | |
| if ( *x > *y ) { | |
| return 1; | |
| } | |
| return 0; | |
| } | |
| /** |
@kgryte I don’t think this part is necessary here
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: passed
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
|
@Sachinn-64 I have removed the sorting code. I now use a simple for loop to fill array in sorted order in the c benchmark file. |
|
For now, aside from the C benchmarks, this PR looks good. Let’s see what Athan suggests. |
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
status: passed
status: passed
status: passed
status: passed
status: na
status: passed
status: na
status: na
status: passed
status: na
status: na
status: na
status: passed
status: passed
status: passed
status: na
status: na
status: passed
status: na
status: passed
Resolves NA
Description
This pull request adds a native C implementation for
stats/base/ndarray/dminsorted.The contribution includes C source code, native tests, benchmarks, and examples, along with updates to the C APIs section in the README. All tests and benchmarks pass successfully.
Related Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
Disclosure
No AI assistance was used in authoring this pull request. All code, tests, benchmarks, documentation, and analysis were written manually.
@stdlib-js/reviewers